package com.sc.nft.entity.vo;

import cn.hutool.core.collection.CollUtil;
import lombok.Data;

import java.util.List;
@Data
public class WebApplicationRequirementWhereVO {
    private List<ApplicationRequirementFactoryVO> andList;

    private List<List<ApplicationRequirementFactoryVO>> orList;

    private Boolean satisfy;

    public Boolean whetherMeetTheRequirement() {
        Boolean satisfy = Boolean.TRUE;
        // andList和orList中的satisfy字段全部为true 则满足 否则为不满足
        if (CollUtil.isNotEmpty(andList)) {
            for (ApplicationRequirementFactoryVO applicationRequirementFactoryVO : andList) {
                if (!applicationRequirementFactoryVO.getSatisfy()) {
                    satisfy=Boolean.FALSE;
                    return satisfy;
                }
            }
        }

        if (CollUtil.isNotEmpty(orList)) {
            // orList中包含多个不同的list,必须每个list中的satisfy都包含true  才是true  否则就是false
            for (List<ApplicationRequirementFactoryVO> applicationRequirementFactoryVOList : orList) {
                Boolean orSatisfy = Boolean.FALSE;
                for (ApplicationRequirementFactoryVO applicationRequirementFactoryVO : applicationRequirementFactoryVOList) {
                    if (applicationRequirementFactoryVO.getSatisfy()) {
                        orSatisfy = Boolean.TRUE;
                        break;
                    }
                }
                if (!orSatisfy) {
                    satisfy=Boolean.FALSE;
                    return satisfy;
                }
            }
        }

        return satisfy;
    }

}
